package org.example;

public class Worker {
    String name;
    int age;
    double salary;
    Adderss addr;

    public Worker(){}
    //有参构造：主要给属性赋值
    public Worker(String name, int age, double salary, Adderss addr) {
        //使用this调用的为对象、属性（可以和局部变量重名），没有则为形参/局部变量
        this.name = name;
        this.age = age;
        this.salary = salary;
        this.addr = addr;
    }
    //无参方法
    public void work(){

    }
    //有参方法
    public void work(int hours){
        System.out.println(name+"工作的小时："+hours);
    }

    @Override
    public String toString() {
        return "Worker{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", salary=" + salary +
                ", addr=" + addr +
                '}';
    }

    public static void main(String[] args) {
        Adderss address =  new Adderss("北京市海淀区清华园1号",100084);
        Worker worker = new Worker("张三", 25, 5500, address);
        System.out.println(worker);

    }

}
